<template>
  <div class="container">
    <div class="sidebar">
      <div class="section-title">数据集</div>
      <el-tree
        :data="data"
        :props="defaultProps"
        @node-click="handleNodeClick"
        accordion
      ></el-tree>
      <div class="section-title">数据开放等级</div>
      <ul class="menu-list">
        <li class="menu-item" v-for="(item, index) in openLevels" :key="index">
          <img :src="item.icon" class="container-icon" />
          <span>{{ item.label }}</span>
        </li>
      </ul>
    </div>
    <div class="content">
      <div class="content-header">
        <el-input
          placeholder="请输入关键词进行搜索"
          prefix-icon="el-icon-search"
          class="search-input"
        ></el-input>
      </div>
      <el-tabs v-model="activeTab" @tab-click="handleTabClick">
        <el-tab-pane label="最近更新" name="recent">
          <div v-if="activeTab === 'recent'" class="content-list">
            <div
              class="list-item"
              v-for="(item, index) in recentData"
              :key="index"
            >
              <div class="tags-content">
                <div class="list-title">{{ item.title }}</div>
                <div class="tags">
                  <el-tag
                    v-for="(tag, tagIndex) in item.tags"
                    :key="tagIndex"
                    >{{ tag }}</el-tag
                  >
                </div>
              </div>
              <div class="list-meta">
                <div>
                  <div class="data-text">{{ item.text }}</div>
                  <div class="data-text">{{ item.date }}</div>
                </div>

                <div class="metrics">
                  <img
                    class="check-icon"
                    src="@/assets/images/data-mart/check.png"
                  />
                  <div>
                    {{ item.views }}
                  </div>
                  <img
                    class="check-icon"
                    src="@/assets/images/data-mart/down.png"
                  />
                  <div>
                    {{ item.downloads }}
                  </div>
                  <img
                    class="check-icon"
                    src="@/assets/images/data-mart/good.png"
                  />
                  <div>{{ item.likes }}</div>
                </div>
              </div>
            </div>
          </div>
        </el-tab-pane>
        <el-tab-pane label="使用最多" name="mostUsed">
          <div v-if="activeTab === 'mostUsed'" class="content-list">
            <div
              class="list-item"
              v-for="(item, index) in mostUsedData"
              :key="index"
            >
              <div class="tags-content">
                <div class="list-title">{{ item.title }}</div>
                <div class="tags">
                  <el-tag
                    v-for="(tag, tagIndex) in item.tags"
                    :key="tagIndex"
                    >{{ tag }}</el-tag
                  >
                </div>
                <div>不予公开</div>
              </div>
              <div class="list-meta">
                <div>
                  <div class="data-text">{{ item.text }}</div>
                  <div class="data-text">{{ item.date }}</div>
                </div>

                <div class="metrics">
                  <img
                    class="check-icon"
                    src="@/assets/images/data-mart/check.png"
                  />
                  <div>
                    {{ item.views }}
                  </div>
                  <img
                    class="check-icon"
                    src="@/assets/images/data-mart/down.png"
                  />
                  <div>
                    {{ item.downloads }}
                  </div>
                  <img
                    class="check-icon"
                    src="@/assets/images/data-mart/good.png"
                  />
                  <div>{{ item.likes }}</div>
                </div>
              </div>
            </div>
          </div>
        </el-tab-pane>
        <el-tab-pane label="点赞最多" name="mostLiked">
          <div v-if="activeTab === 'mostLiked'" class="content-list">
            <div
              class="list-item"
              v-for="(item, index) in mostLikedData"
              :key="index"
            >
              <div class="tags-content">
                <div class="list-title">{{ item.title }}</div>
                <div class="tags">
                  <el-tag
                    v-for="(tag, tagIndex) in item.tags"
                    :key="tagIndex"
                    >{{ tag }}</el-tag
                  >
                </div>
              </div>
              <div class="list-meta">
                <div>
                  <div class="data-text">{{ item.text }}</div>
                  <div class="data-text">{{ item.date }}</div>
                </div>

                <div class="metrics">
                  <img
                    class="check-icon"
                    src="@/assets/images/data-mart/check.png"
                  />
                  <div>
                    {{ item.views }}
                  </div>
                  <img
                    class="check-icon"
                    src="@/assets/images/data-mart/down.png"
                  />
                  <div>
                    {{ item.downloads }}
                  </div>
                  <img
                    class="check-icon"
                    src="@/assets/images/data-mart/good.png"
                  />
                  <div>{{ item.likes }}</div>
                </div>
              </div>
            </div>
          </div>
        </el-tab-pane>
        <el-tab-pane label="浏览最多" name="mostViewed">
          <div v-if="activeTab === 'mostViewed'" class="content-list">
            <div
              class="list-item"
              v-for="(item, index) in mostViewedData"
              :key="index"
            >
              <div class="tags-content">
                <div class="list-title">{{ item.title }}</div>
                <div class="tags">
                  <el-tag
                    v-for="(tag, tagIndex) in item.tags"
                    :key="tagIndex"
                    >{{ tag }}</el-tag
                  >
                </div>
              </div>
              <div class="list-meta">
                <div>
                  <div class="data-text">{{ item.text }}</div>
                  <div class="data-text">{{ item.date }}</div>
                </div>
                <span class="data-text">{{ item.date }}</span>

                <div class="metrics">
                  <img
                    class="check-icon"
                    src="@/assets/images/data-mart/check.png"
                  />
                  <div>
                    {{ item.views }}
                  </div>
                  <img
                    class="check-icon"
                    src="@/assets/images/data-mart/down.png"
                  />
                  <div>
                    {{ item.downloads }}
                  </div>
                  <img
                    class="check-icon"
                    src="@/assets/images/data-mart/good.png"
                  />
                  <div>{{ item.likes }}</div>
                </div>
              </div>
            </div>
          </div>
        </el-tab-pane>
      </el-tabs>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalItems"
        class="pagination"
      ></el-pagination>
    </div>
    <div class="right-content">热搜-hot news</div>
  </div>
</template>

<script>
import messageIcon from "@/assets/images/data-mart/message.png";
import textIcon from "@/assets/images/data-mart/text.png";
import lockIcon from "@/assets/images/data-mart/lock.png";

export default {
  name: "dataMart",

  data() {
    return {
      activeTab: "recent",
      data: [
        {
          label: "CIM 数据集",
          children: [
            { label: "基础地理" },
            { label: "遥感影像" },
            { label: "地形地貌" },
            { label: "行政区划" },
            { label: "建筑物膜" },
            { label: "城市道路" },
            { label: "水域河流" },
          ],
        },
        {
          label: "一标三实数据集",
          children: [{ label: "编码码表数据集" }, { label: "第三方数据集" }],
        },
      ],
      defaultProps: {
        children: "children",
        label: "label",
      },
      openLevels: [
        { label: "完全公开", icon: messageIcon },
        { label: "社区公开", icon: textIcon },
        { label: "依申请公开", icon: lockIcon },
        { label: "不予公开", icon: messageIcon },
      ],
      recentData: [
        {
          title: "武汉市基础地理数据",
          date: "2024-04-01 更新",
          text: "武汉市标准地址信息。",
          tags: ["CIM数据集", "城市道路"],
          views: 15.3,
          downloads: 30,
          likes: 9,
        },
        {
          title: "武汉市标准地址数据",
          date: "2024-04-01 更新",
          text: "武汉市道路的几何形状、交通信号、路标、路面状况等信息。",
          tags: ["一标三实数据集", "编码码表"],
          views: 15.3,
          downloads: 30,
          likes: 9,
        },
        {
          title: "武汉市实有人口数据",
          date: "2024-04-01 更新",
          text: "武汉市实时人口数据。",
          tags: ["CIM数据集", "城市道路"],
          views: 15.3,
          downloads: 30,
          likes: 9,
        },
      ],
      mostUsedData: [
        //  "使用最多"
      ],
      mostLikedData: [
        // "点赞最多"
      ],
      mostViewedData: [
        //  "浏览最多"
      ],
      currentPage: 1,
      pageSize: 5,
      totalItems: 6532,
    };
  },
  methods: {
    handleNodeClick(data) {
      console.log("Node clicked:", data.label);
    },
    handleSizeChange(size) {
      this.pageSize = size;
      console.log("Page size changed to:", size);
    },
    handleCurrentChange(page) {
      this.currentPage = page;
      console.log("Current page changed to:", page);
    },
    handleTabClick(tab) {
      console.log("Tab clicked:", tab.name);
    },
  },
};
</script>

<style scoped lang="scss">
.container {
  display: flex;
  justify-content: space-around;
  width: 100%;
  height: 100%;
  padding: 4px 30px;
}
.el-tree {
  margin-bottom: 10px !important;
}
.sidebar {
  width: 200px;
  padding: 20px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.section-title {
  font-weight: bold;
  margin-bottom: 10px;
  font-size: 12px;
  color: rgb(51, 51, 51);
  font-family: 思源黑体;
}

.menu-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.menu-item {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  cursor: pointer;
  color: #333;
}

.menu-item span {
  line-height: 12px;
  letter-spacing: 0px;
  text-align: left;
  font-size: 12px;
  color: rgb(68, 75, 86);
  font-family: 思源黑体;
}

.menu-item:hover {
  color: #4a90e2;
}

.container-icon {
  width: 8px;
  height: 8px;
  margin-right: 5px;
}

.content {
  flex: 1;
  padding: 20px;
}

.content-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.search-input {
  width: 300px;
}

.content-list {
  background-color: #fff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  border-radius: 5px;
  padding: 20px;
}

.list-item {
  margin-bottom: 20px;
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 10px;
  .tags-content {
    display: flex;
    justify-content: space-between;
  }
}

.list-title {
  color: rgb(51, 51, 51);
  font-family: 思源黑体;
  font-size: 15px;
  font-weight: 700;
  line-height: 20px;
  letter-spacing: 0px;
  text-align: left;
}

.list-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .data-text {
    color: rgb(102, 102, 102);
    font-family: 思源黑体;
    font-size: 14px;
    font-weight: 400;
    line-height: 24.12px;
    letter-spacing: 14%;
    text-align: left;
  }
}

.tags {
  display: flex;
  gap: 10px;
}

.metrics {
  display: flex;
  align-items: center;
  gap: 10px;
  div {
    color: rgb(102, 102, 102);
    font-family: 思源黑体;
    font-size: 16px;
    font-weight: 400;
    line-height: 23px;
    letter-spacing: 0px;
    text-align: left;
  }
}

.metrics el-icon {
  font-size: 16px;
  color: #666;
}

.pagination {
  margin-top: 20px;
  text-align: right;
}
.el-icon-view {
  width: 10px;
  height: 0.05rem;
}
.check-icon {
  width: 14px;
  height: 13px;
  margin-right: -8px;
}

.right-content {
  border: 1px solid red;
}
</style>
